package cn.com.nes.site.action.user;

import cn.com.nes.common.util.*;
import cn.com.nes.common.wx.WeChatUtils;
import cn.com.nes.common.wx.WeChatUtils_HotLink;
import cn.com.nes.common.wx.WxAuth;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.UserInfo;
import cn.com.nes.site.module.service.H5Service;
import cn.com.nes.site.module.service.crm.ClueService;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.SQLException;
import java.util.*;

@Controller("h5")
@RequestMapping("/h5")
public class H5Action {
	
	@Resource
	private H5Service service;
	
	@Resource
	private ClueService service_clue;

	@RequestMapping(method = RequestMethod.GET, value = "/getScene")
	public @ResponseBody  PageData getScene(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getScene(req) ;
			return res;
	}
	
	
	
	//小程序
	@RequestMapping(method = RequestMethod.POST, value = "/addUsers")
	public @ResponseBody  PageData addUsers(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			
			DataReq req = req_Status.getReq() ;
			PageData restmp = service_clue.getActivityByID(req) ;
			if(restmp.getRetCode()!=0) {
				res.setRetCode(1) ;
				res.setRetMessage("没有查询到该活动信息！");
				return res ;
			}
			
			String code = (String)req.getReqData().get("verCode") ;
			String phone = (String)req.getReqData().get("phone") ;
				
			if(!StringUtils.isEmpty(code)) {
				if(!ValidCodeUtil.validCode(phone, code)) {
					res.setRetCode(1) ;
					res.setRetMessage("验证码错误！");
					return res ;
				}
			}
			
			String encryptedData = (String) req.getReqData().get("encryptedData") ;
			if(!StringUtils.isEmpty(encryptedData)) {
				String sessionKey = (String) req.getReqData().get("sessionKey") ;
				String iv = (String) req.getReqData().get("iv") ;
				JSONObject jsonObject = WeChatUtils.getUserInfo(encryptedData, sessionKey, iv);
				req.getReqData().put("phone", jsonObject.getString("phoneNumber")) ; //跟进状态
			}
			
			UserInfo uinfo = new UserInfo();
			uinfo.setId((String)restmp.getData().get("createUid"));
			uinfo.setCompanyId((String)restmp.getData().get("companyId"));
			req.setUinfo(uinfo );
			req.getReqData().put("active_info", restmp.getData()) ;
			req.getReqData().put("isLog", "0") ;
			
			String name = (String) req.getReqData().get("name") ;
			if(StringUtils.isEmpty(name)) {
				req.getReqData().put("name", req.getReqData().get("personincharge")) ;
			}
			req.getReqData().put("openid", req.getReqData().get("openId")) ;
			res = service.addUsers(req) ;
			if(res.getRetCode()==0) {
				req.getReqData().put("followupstatus", "01") ; //跟进状态
				req.getReqData().put("poolentrymode", "05") ; //线索池
				req.getReqData().put("culestate", "01") ; //线索状态，新线索
				req.getReqData().put("cluestage", "02") ; //跟进状态
				req.getReqData().put("cluesource", restmp.getData().get("cluesource")) ; //跟进状态
				req.getReqData().put("pooltype", "03") ;
				String xzqhdm = service_clue.getAreaCodeByPhone(req);
				req.getReqData().put("xzqhdm",xzqhdm) ;
				req.getReqData().put("isRl","0") ;
				req.getReqData().put("advertisementId",restmp.getData().get("uuid")) ;
				req.getReqData().put("cluename", req.getReqData().get("companyName")) ;
				req.getReqData().put("cluebelongtocompany", restmp.getData().get("companyId")) ;
				req.getReqData().put("projectname", req.getReqData().get("companyName")) ;
				req.getReqData().put("personincharge",req.getReqData().get("name")) ;
				req.getReqData().put("cluephone",req.getReqData().get("phone") ) ;
				req.getReqData().put("projectaddress",null) ;
				req.getReqData().put("uuid",null) ;
				restmp = service_clue.addClue(req) ;
			}
			return res;
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/getFileList")
	public @ResponseBody  PageData getFileList(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getFileList(req) ;
			return res;
	}
	
	
	@RequestMapping(method = RequestMethod.GET, value = "/getOpenIdAndSessionKey")
	public @ResponseBody  PageData getOpenID(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			String code = (String) req.getReqData().get("code") ;
			String json = WeChatUtils.getOpenIdAndSessionKey(code);
			WxAuth wxAuth = (WxAuth)JsonUtil.getObjFromStr(json, WxAuth.class) ;
			if (wxAuth.getErrcode()!= 0) {
				res.setRetCode(9);
				res.setRetMessage(wxAuth.getErrmsg());
				return res;
		    }
			res.setRetCode(0);
			res.setRetMessage("OK");
			wxAuth.setReg(0);
			req.getReqData().put("openid", wxAuth.getOpenid()) ;
			PageData resTmp = service.getActiveUser(req) ;
			if(resTmp.getRetCode()==0 && resTmp.getPage().size()>0) {
				wxAuth.setReg(1);
			}
			
			res.setExtData(wxAuth);
			return res ;
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/getActivityURL")
	public @ResponseBody  PageData getActivityURL(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			
			DataReq req = req_Status.getReq() ;
			PageData resTmp = service.getActiveSession(req) ;
			Map<String,String> e= new HashMap<String, String>();
			if(resTmp.getRetCode()==0) {
				
				String indexTemplate = (String) resTmp.getData().get("indexTemplate") ;
				String uuid = (String) resTmp.getData().get("uuid") ;
				String activityUuid = (String) resTmp.getData().get("activityUuid") ;
				e.put("url", "https://heat.nes.com.cn:8202/#/g_choujiang?uuid="+uuid+"&indexTemplate="+indexTemplate+"&id="+activityUuid) ;
				e.put("id", activityUuid) ;
			}else {
				if(resTmp.getRetCode()==1) {
					e.put("url", (String) resTmp.getData().get("url") ) ;
					e.put("id", (String) resTmp.getData().get("id")) ;
				}
			}
			
			res.setExtData(e);
			res.setRetCode(0);
			res.setRetMessage("OK");

			return res ;
	}
	
	
	//PC-查询活动信息
	@RequestMapping(method = RequestMethod.GET, value = "/getActiveList")
	public @ResponseBody  PageData getActiveList(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getActiveList(req) ;
			return res;
	}
	
	//PC-保存活动信息
    @RequestMapping(method = RequestMethod.POST, value = "/saveActive")
    public @ResponseBody
    PageData saveActive(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = service.saveActive(reqStatus.getReq());
        return res;
    }
    
    //PC-删除活动信息
    @RequestMapping(method = RequestMethod.POST, value = "/delActive")
    public @ResponseBody
    PageData delActive(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = service.delActive(reqStatus.getReq());
        return res;
    }
    
    //PC-数据字典
    @RequestMapping(method = RequestMethod.POST, value = "/getParamSelect")
    public @ResponseBody
    PageData getParamSelect(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = service.getParamSelect(reqStatus.getReq());
        return res;
    }

    //APP-保存用户信息
    @RequestMapping(method = RequestMethod.POST, value = "/saveActiveUser")
    public @ResponseBody
    PageData saveActiveUser(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, false);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        //String xzqhdm = service_clue.getAreaCodeByPhone(reqStatus.getReq());
        //reqStatus.getReq().getReqData().put("xzqhdm", xzqhdm);
        res = service.saveActiveUser(reqStatus.getReq());
        return res;
    }
    
    //APP-查询活动信息
  	@RequestMapping(method = RequestMethod.GET, value = "/getActiveByUuid")
  	public @ResponseBody  PageData getActiveByUuid(HttpServletRequest request,
  			HttpServletResponse response, ModelMap modelMap) throws Exception {
  			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
  			PageData res = new PageData() ;
  			if (req_Status.getRetCode() != 0) {
  				res = new PageData();
  				res.setRetCode(req_Status.getRetCode()) ;
  				res.setRetMessage(req_Status.getRetMessage());
  				return res;
  			}	
  			DataReq req = req_Status.getReq() ;
  			res = service.getActiveByUuid(req) ;
  			return res;
  	}
  	
  	//热链产业小程序
	@RequestMapping(method = RequestMethod.POST, value = "/addHotLinkUsers")
	public @ResponseBody  PageData addHotLinkUsers(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			
			DataReq req = req_Status.getReq() ;
			PageData restmp = service_clue.getActivityByID(req) ;
			if(restmp.getRetCode()!=0) {
				res.setRetCode(1) ;
				res.setRetMessage("没有查询到该活动信息！");
				return res ;
			}
			
			String encryptedData = (String) req.getReqData().get("encryptedData") ;
			if(!StringUtils.isEmpty(encryptedData)) {
				String sessionKey = (String) req.getReqData().get("sessionKey") ;
				String iv = (String) req.getReqData().get("iv") ;
				JSONObject jsonObject = WeChatUtils_HotLink.getUserInfo(encryptedData, sessionKey, iv);
				req.getReqData().put("phone", jsonObject.getString("phoneNumber")) ; //跟进状态
			}
			
			UserInfo uinfo = new UserInfo();
			uinfo.setId((String)restmp.getData().get("createUid"));
			uinfo.setCompanyId((String)restmp.getData().get("companyId"));
			req.setUinfo(uinfo );
			req.getReqData().put("active_info", restmp.getData()) ;
			req.getReqData().put("isLog", "0") ;
			
			String name = (String) req.getReqData().get("name") ;
			if(StringUtils.isEmpty(name)) {
				req.getReqData().put("name", req.getReqData().get("personincharge")) ;
			}
			req.getReqData().put("openid", req.getReqData().get("openId")) ;
			res = service.addUsers(req) ;
			if(res.getRetCode()==0) {
				req.getReqData().put("followupstatus", "01") ; //跟进状态
				req.getReqData().put("poolentrymode", "05") ; //线索池
				req.getReqData().put("culestate", "02") ; //线索状态，新线索
				req.getReqData().put("cluestage", "01") ; //跟进状态
				req.getReqData().put("cluesource", restmp.getData().get("cluesource")) ; //跟进状态
				req.getReqData().put("pooltype",  "其他") ;
				String xzqhdm = service_clue.getAreaCodeByPhone(req);
				req.getReqData().put("xzqhdm",xzqhdm) ;
				req.getReqData().put("isRl","0") ;
				req.getReqData().put("advertisementId",restmp.getData().get("uuid")) ;
				req.getReqData().put("cluename", req.getReqData().get("companyName")) ;
				req.getReqData().put("cluebelongtocompany", restmp.getData().get("companyId")) ;
				req.getReqData().put("projectname", req.getReqData().get("companyName")) ;
				req.getReqData().put("personincharge",req.getReqData().get("name")) ;
				req.getReqData().put("cluephone",req.getReqData().get("phone") ) ;
				req.getReqData().put("projectaddress",null) ;
				req.getReqData().put("uuid",null) ;
				restmp = service_clue.addClue(req) ;
			}
			return res;
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "/getHotLinkOpenIdAndSessionKey")
	public @ResponseBody  PageData getHotLinkOpenIdAndSessionKey(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			String code = (String) req.getReqData().get("code") ;
			String json = WeChatUtils_HotLink.getOpenIdAndSessionKey(code);
			WxAuth wxAuth = (WxAuth)JsonUtil.getObjFromStr(json, WxAuth.class) ;
			if (wxAuth.getErrcode()!= 0) {
				res.setRetCode(9);
				res.setRetMessage(wxAuth.getErrmsg());
				return res;
		    }
			res.setRetCode(0);
			res.setRetMessage("OK");
			wxAuth.setReg(0);
			req.getReqData().put("openid", wxAuth.getOpenid()) ;
			PageData resTmp = service.getActiveUser(req) ;
			if(resTmp.getRetCode()==0 && resTmp.getPage().size()>0) {
				wxAuth.setReg(1);
			}
			
			res.setExtData(wxAuth);
			return res ;
	}
	
	// 上传文件
	@RequestMapping(method = RequestMethod.POST, value = "/uploadPPTFile")
	public @ResponseBody PageData uploadPPTFile(@RequestParam("file") MultipartFile file, HttpServletRequest request,
			HttpServletResponse response) throws IllegalStateException, IOException {
	/*	DataRes req_Status = DBUtils.setRemoteVisit(request, response, false);*//*

		if (req_Status.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(req_Status.getRetCode());
			res.setRetMessage(req_Status.getRetMessage());
			return res;
		}*/
		PageData res = new PageData();
		// 判断文件是否为空，空则返回失败页面
		if (file.isEmpty()) {
			res.setRetCode(9);
			res.setRetMessage("文件不能为空！");
			return res;
		}

		String uuid = UUID.randomUUID().toString() ;
		String rootPath = System.getProperty("catalina.home")+File.separator+"webapps"+File.separator+"TServImage" ;
		String curDate = DBUtils.getDate(0);
		String filePath = rootPath + File.separator + curDate + File.separator+ uuid + File.separator;
		
		String fileName = file.getOriginalFilename();
		String suffix = fileName.substring(fileName.lastIndexOf("."));
			
		fileName = uuid + suffix;
		
		String webPath = "/TServImage/"+curDate+"/"+uuid;
		File fileDest = new File(filePath, fileName);
		if (!fileDest.getParentFile().exists()) {
			fileDest.getParentFile().mkdirs();
			System.out.println("创建目录" + filePath);
		}

		file.transferTo(fileDest);
		
		List<byte[]> images = null ;
		if(fileName.toLowerCase().indexOf("pdf")>0) {
			images = PdfToImageUtil.pdfToImage(filePath + fileName) ;
		}else {
			images = PPTUtil.pptx2Image(new FileInputStream(new File(filePath + fileName)),3);
		}
		
		// 输出图片
		List<String> imgList = new ArrayList<String>();
        for (int i = 1; i <= images.size(); i++) {
        	String tmpfileName = i + ".png";
            String path = filePath +tmpfileName;
            FileOutputStream output = new FileOutputStream(path);
            IOUtils.write(images.get(i-1), output);
            IOUtils.closeQuietly(output);
            imgList.add(webPath+"/"+tmpfileName) ;
        }
        
        
        Map<String, Object> data = new LinkedHashMap<String, Object>();
        data.put("uuid", uuid) ;
        data.put("images", imgList) ;
		res.setData(data );
		res.setRetCode(0);
		res.setRetMessage("OK");
		return res;
	}
	
	// 上传文件
	@RequestMapping(method = RequestMethod.POST, value = "/uploadImgFile")
	public @ResponseBody PageData uploadImgFile(@RequestParam("file") MultipartFile file, HttpServletRequest request,
			HttpServletResponse response) throws IllegalStateException, IOException {
		DataRes req_Status = DBUtils.setRemoteVisit(request, response, false);
		PageData res = new PageData();
		if (req_Status.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(req_Status.getRetCode());
			res.setRetMessage(req_Status.getRetMessage());
			return res;
		}
		// 判断文件是否为空，空则返回失败页面
		if (file.isEmpty()) {
			res.setRetCode(9);
			res.setRetMessage("文件不能为空！");
			return res;
		}

		String uuid = UUID.randomUUID().toString() ;
		String rootPath = System.getProperty("catalina.home")+File.separator+"webapps"+File.separator+"TServImage" ;
		String curDate = DBUtils.getDate(0);
		String filePath = rootPath + File.separator + curDate + File.separator+ uuid + File.separator;
		
		String fileName = file.getOriginalFilename();
		String suffix = fileName.substring(fileName.lastIndexOf("."));
			
		fileName = uuid + suffix;
		
		String webPath = "/TServImage/"+curDate+"/"+uuid;
		File fileDest = new File(filePath, fileName);
		if (!fileDest.getParentFile().exists()) {
			fileDest.getParentFile().mkdirs();
			System.out.println("创建目录" + filePath);
		}

		file.transferTo(fileDest);
		
        Map<String, Object> data = new LinkedHashMap<String, Object>();
        data.put("webPath", webPath+"/"+fileName) ;
		res.setData(data );
		res.setRetCode(0);
		res.setRetMessage("OK");
		return res;
	}	
  	
	//小程序-保存用户收藏记录
  	@RequestMapping(method = RequestMethod.POST, value = "/saveCollectRecord")
  	public @ResponseBody  PageData saveCollectRecord(HttpServletRequest request,
  			HttpServletResponse response, ModelMap modelMap) throws Exception {
  			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
  			PageData res = new PageData() ;
  			if (req_Status.getRetCode() != 0) {
  				res = new PageData();
  				res.setRetCode(req_Status.getRetCode()) ;
  				res.setRetMessage(req_Status.getRetMessage());
  				return res;
  			}	
  			DataReq req = req_Status.getReq() ;
  			res = service.saveCollectRecord(req) ;
  			return res;
  	}
  	
  	//小程序-获取个人收藏
  	@RequestMapping(method = RequestMethod.POST, value = "/getPersonalCollect")
  	public @ResponseBody  PageData getPersonalCollect(HttpServletRequest request,
  			HttpServletResponse response, ModelMap modelMap) throws Exception {
  			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
  			PageData res = new PageData() ;
  			if (req_Status.getRetCode() != 0) {
  				res = new PageData();
  				res.setRetCode(req_Status.getRetCode()) ;
  				res.setRetMessage(req_Status.getRetMessage());
  				return res;
  			}	
  			DataReq req = req_Status.getReq() ;
  			res = service.getPersonalCollect(request,req) ;
  			return res;
  	}
  	
  	//小程序-获取推荐资料
  	@RequestMapping(method = RequestMethod.POST, value = "/getRecommendData")
  	public @ResponseBody  PageData getRecommendData(HttpServletRequest request,
  			HttpServletResponse response, ModelMap modelMap) throws Exception {
  			DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
  			PageData res = new PageData() ;
  			if (req_Status.getRetCode() != 0) {
  				res = new PageData();
  				res.setRetCode(req_Status.getRetCode()) ;
  				res.setRetMessage(req_Status.getRetMessage());
  				return res;
  			}	
  			DataReq req = req_Status.getReq() ;
  			res = service.getRecommendData(request,req) ;
  			return res;
  	}

	//PC-查询活动信息
	@RequestMapping(method = RequestMethod.GET, value = "/getPosterList")
	public @ResponseBody  PageData getPosterList(HttpServletRequest request,
												 HttpServletResponse response, ModelMap modelMap) throws Exception {
		DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
		PageData res = new PageData() ;
		if (req_Status.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(req_Status.getRetCode()) ;
			res.setRetMessage(req_Status.getRetMessage());
			return res;
		}
		DataReq req = req_Status.getReq() ;
		res = service.getPosterList(req) ;
		return res;
	}

	//PC-查询活动信息
	@RequestMapping(method = RequestMethod.GET, value = "/getPosterDetail")
	public @ResponseBody  PageData getPosterDetail(HttpServletRequest request,
												 HttpServletResponse response, ModelMap modelMap) throws Exception {
		DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
		PageData res = new PageData() ;
		if (req_Status.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(req_Status.getRetCode()) ;
			res.setRetMessage(req_Status.getRetMessage());
			return res;
		}
		DataReq req = req_Status.getReq() ;
		res = service.getPosterDetail(req) ;
		return res;
	}

	//PC-保存活动信息
	@RequestMapping(method = RequestMethod.POST, value = "/savePoster")
	public @ResponseBody
	PageData savePoster(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
		DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
		PageData res;
		if (reqStatus.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(reqStatus.getRetCode());
			res.setRetMessage(reqStatus.getRetMessage());
			return res;
		}
		res = service.savePoster(reqStatus.getReq());
		return res;
	}

	//PC-删除活动信息
	@RequestMapping(method = RequestMethod.POST, value = "/delPoster")
	public @ResponseBody
	PageData delPoster(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
		DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
		PageData res;
		if (reqStatus.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(reqStatus.getRetCode());
			res.setRetMessage(reqStatus.getRetMessage());
			return res;
		}
		res = service.delPoster(reqStatus.getReq());
		return res;
	}

	@RequestMapping(method = RequestMethod.GET, value = "/getPosterList_xcx")
	public @ResponseBody  PageData getPosterList_xcx(HttpServletRequest request,
												 HttpServletResponse response, ModelMap modelMap) throws Exception {
		DataRes req_Status = DBUtils.setRemoteVisit(request, response,false);
		PageData res = new PageData() ;
		if (req_Status.getRetCode() != 0) {
			res = new PageData();
			res.setRetCode(req_Status.getRetCode()) ;
			res.setRetMessage(req_Status.getRetMessage());
			return res;
		}
		DataReq req = req_Status.getReq() ;
		res = service.getPosterList_xcx(req) ;
		return res;
	}
}
